package com.tools.pojo.data;


import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AnalysisResponseDTO {

    /**
     * 是否成功
     */
    private boolean success;

    /**
     * 消息
     */
    private String message;

    /**
     * 流程实例ID
     */
    private Long instanceId;

    /**
     * 业务标识
     */
    private String businessKey;

    /**
     * 分析类型
     */
    private String analysisType;

    /**
     * 数据格式
     */
    private String dataFormat;

    /**
     * 预估记录数
     */
    private Integer estimatedRecords;

    /**
     * 时间戳
     */
    private Long timestamp;

    /**
     * 错误代码（失败时）
     */
    private String errorCode;

    /**
     * 错误详情（失败时）
     */
    private Object errorDetails;

    // 成功响应构造方法
    public static AnalysisResponseDTO success(Long instanceId, String businessKey,
                                              String analysisType, String message) {
        AnalysisResponseDTO response = new AnalysisResponseDTO();
        response.setSuccess(true);
        response.setInstanceId(instanceId);
        response.setBusinessKey(businessKey);
        response.setAnalysisType(analysisType);
        response.setMessage(message);
        response.setTimestamp(System.currentTimeMillis());
        return response;
    }

    // 失败响应构造方法
    public static AnalysisResponseDTO failure(String message) {
        return failure(message, null, null);
    }

    public static AnalysisResponseDTO failure(String message, String errorCode, Object errorDetails) {
        AnalysisResponseDTO response = new AnalysisResponseDTO();
        response.setSuccess(false);
        response.setMessage(message);
        response.setErrorCode(errorCode);
        response.setErrorDetails(errorDetails);
        response.setTimestamp(System.currentTimeMillis());
        return response;
    }
}